package com.reger.l2cache.bloomfilter;

import org.springframework.data.redis.connection.RedisConnectionFactory;

public class BloomFilterFactory {

	private final RedisConnectionFactory connectionFactory;

	public BloomFilterFactory(RedisConnectionFactory connectionFactory) {
		super();
		this.connectionFactory = connectionFactory;
	}

	/**
	 * 创建默认hash大小的BloomFilter
	 * 
	 * @param key    BloomFilterKey
	 * @param values String
	 * @return this
	 */
	public BloomFilter create(String key, String... values) {
		BloomFilter bloomFilter = new BloomFilter(connectionFactory, key);
		bloomFilter.add(values);
		return bloomFilter;
	}

	/**
	 * 创建指定hash大小的BloomFilter
	 * 
	 * @param key    BloomFilterKey
	 * @param size   BloomFilterSize
	 * @param values String
	 * @return this
	 */
	public BloomFilter create(String key, long size, String... values) {
		BloomFilter bloomFilter = new BloomFilter(connectionFactory, key, size);
		bloomFilter.add(values);
		return bloomFilter;
	}
}
